package com.slg.android.manyanime.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by Thinkpad on 2015/3/13.
 */
public class CartoonDetail implements Serializable{
    private String name;
    private String lastup;
    private String update_time;
    private String isOver;
    private String cover;
    private String artist;
    private String intro;
    private String area;
    private String category;
    private String praiseNum;

    private String comment_num;
    private String score_total_num;
    private String score_person_num;
    private String id;
    private String score;

    private List<Hua> juan;
    private List<Category> categorys;
    private List<Hua> fanwai;

    private List<WatchUser> watches;
    private List<Hua> huas ;
    private static final long serialVersionUID = 2L;

    public List<Hua> getJuan() {
        return juan;
    }

    public void addJuan(Hua hua) {
        this.juan.add(hua);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastup() {
        return lastup;
    }

    public void setLastup(String lastup) {
        this.lastup = lastup;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public String getIsOver() {
        return isOver;
    }

    public void setIsOver(String isOver) {
        this.isOver = isOver;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getPraiseNum() {
        return praiseNum;
    }

    public void setPraiseNum(String praiseNum) {
        this.praiseNum = praiseNum;
    }

    public String getComment_num() {
        return comment_num;
    }

    public void setComment_num(String comment_num) {
        this.comment_num = comment_num;
    }

    public String getScore_total_num() {
        return score_total_num;
    }

    public void setScore_total_num(String score_total_num) {
        this.score_total_num = score_total_num;
    }

    public String getScore_person_num() {
        return score_person_num;
    }

    public void setScore_person_num(String score_person_num) {
        this.score_person_num = score_person_num;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }

    public List<Category> getCategorys() {
        return categorys;
    }

    public void setCategorys(List<Category> categorys) {
        this.categorys = categorys;
    }

    public List<Hua> getFanwai() {
        return fanwai;
    }

    public void setFanwai(List<Hua> fanwai) {
        this.fanwai = fanwai;
    }

    public List<WatchUser> getWatches() {
        return watches;
    }

    public List<Hua> getHuas() {
        return huas;
    }

    public void addWatcher(WatchUser user) {
        this.watches.add(user);
    }

    public void addHua(Hua hua) {
        this.huas.add(hua);

    }

    public void addCategory(Category category) {
        this.categorys.add(category);
    }

    public void addFanwai(Hua fanwai) {
        this.fanwai.add(fanwai);
    }


    public CartoonDetail() {
        this.huas = new ArrayList<>();
        this.watches = new ArrayList<>();
        this.categorys = new ArrayList<>();
        this.fanwai = new ArrayList<>();
        this.juan = new ArrayList<>();


    }

    public void parseJson(JSONObject object) {

        try {
            name = object.getString("name");
            lastup = object.getString("lastup");
            update_time = object.getString("update_time");
            isOver = object.getString("isOver");
            cover = object.getString("cover");
            artist = object.getString("artist");
            intro = object.getString("intro");
            area = object.getString("area");
            category = object.getString("category");
            praiseNum = object.getString("praiseNum");
            comment_num = object.getString("comment_num");
            score_total_num = object.getString("score_total_num");
            score_person_num = object.getString("score_person_num");
            id = object.getString("id");
            score = object.getString("score");

            JSONArray catearray = object.getJSONArray("categorys");
            for (int i = 0; i < catearray.length(); i++) {
                JSONObject object1 = catearray.getJSONObject(i);
                Category category1 = new Category();
                category1.paresJson(object1);
                this.categorys.add(category1);
            }

            JSONArray fanwaiarray = object.getJSONArray("fanwai");
            for (int i = 0; i < fanwaiarray.length(); i++) {

                Hua hua = new Hua();
                hua.parseJson(fanwaiarray.getJSONObject(i));
                this.fanwai.add(hua);
            }

            JSONArray watchUserarray = object.getJSONArray("watchUser");

            for (int i = 0; i < watchUserarray.length(); i++) {
                WatchUser watchUser = new WatchUser();
                watchUser.parseJson(watchUserarray.getJSONObject(i));
                this.watches.add(watchUser);

            }

            JSONArray huaarray = object.getJSONArray("hua");
            for (int i = 0; i < huaarray.length(); i++) {
                Hua hua1 = new Hua();
                hua1.parseJson(huaarray.getJSONObject(i));
                this.huas.add(hua1);

            }

            JSONArray juanarray = object.getJSONArray("juan");
            for (int i = 0; i < juanarray.length(); i++) {
                Hua hua2 = new Hua();
                hua2.parseJson(juanarray.getJSONObject(i));
                this.juan.add(hua2);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    @Override
    public String toString() {
        return "CartoonDetail{" +
                "name='" + name + '\'' +
                ", lastup='" + lastup + '\'' +
                ", update_time='" + update_time + '\'' +
                ", isOver='" + isOver + '\'' +
                ", cover='" + cover + '\'' +
                ", artist='" + artist + '\'' +
                ", intro='" + intro + '\'' +
                ", area='" + area + '\'' +
                ", category='" + category + '\'' +
                ", praiseNum='" + praiseNum + '\'' +
                ", comment_num='" + comment_num + '\'' +
                ", score_total_num='" + score_total_num + '\'' +
                ", score_person_num='" + score_person_num + '\'' +
                ", id='" + id + '\'' +
                ", score='" + score + '\'' +
                ", juan=" + juan +
                ", categorys=" + categorys +
                ", fanwai=" + fanwai +
                ", watches=" + watches +
                ", huas=" + huas +
                '}';
    }
}
